<?php   if(!defined('BASEPATH')) exit ('No direct script access allowed');
    /**
     * eg: change ô to o
     */
    if(!function_exists('remove_accents'))
    {
        function remove_accents($str)
    	{
        	$search = array(
                            'à','á','ạ','ả','ã','â','ầ','ấ','ậ','ẩ','ẫ','ă','ằ','ắ','ặ','ẳ','ẵ',
                            'è','é','ẹ','ẻ','ẽ','ê','ề','ế','ệ','ể','ễ',
    						'ì','í','ị','ỉ','ĩ',
    						'ò','ó','ọ','ỏ','õ','ô','ồ','ố','ộ','ổ','ỗ','ơ','ờ','ớ','ợ','ở','ỡ',
    						'ù','ú','ụ','ủ','ũ','ư','ừ','ứ','ự','ử','ữ',
    						'ỳ','ý','ỵ','ỷ','ỹ',
    						'đ',
    						'À','Á','Ạ','Ả','Ã','Â','Ầ','Ấ','Ậ','Ẩ','Ẫ','Ă','Ằ','Ắ','Ặ','Ẳ','Ẵ',
    						'È','É','Ẹ','Ẻ','Ẽ','Ê','Ề','Ế','Ệ','Ể','Ễ',
    						'Ì','Í','Ị','Ỉ','Ĩ',
    						'Ò','Ó','Ọ','Ỏ','Õ','Ô','Ồ','Ố','Ộ','Ổ','Ỗ','Ơ','Ờ','Ớ','Ợ','Ở','Ỡ',
    						'Ù','Ú','Ụ','Ủ','Ũ','Ư','Ừ','Ứ','Ự','Ử','Ữ',
    						'Ỳ','Ý','Ỵ','Ỷ','Ỹ',
    						'Đ');
    
    		$replace = array(
                            'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a',
    						'e','e','e','e','e','e','e','e','e','e','e',
    						'i','i','i','i','i',
    						'o','o','o','o','o','o','o','o','o','o','o','o','o','o','o','o','o',
    						'u','u','u','u','u','u','u','u','u','u','u',
    						'y','y','y','y','y',
    						'd',
    						'A','A','A','A','A','A','A','A','A','A','A','A','A','A','A','A','A',
    						'E','E','E','E','E','E','E','E','E','E','E',
    						'I','I','I','I','I',
    						'O','O','O','O','O','O','O','O','O','O','O','O','O','O','O','O','O',
    						'U','U','U','U','U','U','U','U','U','U','U',
    						'Y','Y','Y','Y','Y',
    						'D');
                            
    		return str_replace($search, $replace, $str);
    	}
    }
    /**
     * using to get alias or ...
     */
    if(!function_exists('standardize_url'))
    {
        function standardize_url($str)
    	{
    		$search =  array(' ', '/', '&', '<', '>', ',', '\'', '?', '(', ')', '.' );
    		$replace = array('-', '-', '-', '-', '-', '-', '-' , '-', '-', '-', '-' );
    		return remove_accents(str_replace($search, $replace, $str));
    	}
    }
    /**
     * using format money
    */
    if(!function_exists('format_money'))
    {
        function format_money($number)
        {
            if(is_numeric($number))
            {
                $str_nb = (string)$number;
                $len_num = strlen($str_nb);
                $money='';
                if($len_num > 3)
                {
                    $j=0;
                    for($i = $len_num - 1; $i >= 0 ; $i--)
                    {
                        $j+=1;
                        if($j % 3 == 0 && $j<$len_num)
                        {
                            $money='.'.$str_nb[$i].$money;
                        }
                        else
                        {
                            $money=$str_nb[$i].$money;
                        }
                    }
                }
                else
                {
                    $money=$str_nb;
                }
                return $money.'&nbsp;&#8363;';
            }
            else
            {
                return '0&nbsp;&#8363;';
            }
        }
    }
    
    //end file common_function_helper.php
?>